package com.aigou.admin.controller;


import com.aigou.admin.entity.User;
import com.aigou.admin.service.UserService;
import com.aigou.admin.service.impl.UserServiceImpl;
import com.alibaba.fastjson2.JSON;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


@WebServlet("/deleteUser")
public class DeleteUserController extends HttpServlet {
    private UserService userService = new UserServiceImpl();


    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req,resp);
    }
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获得用户id
        String userId = req.getParameter("userId");
        // 执行删除操作
        boolean isDeleted = userService.remove(userId);

        resp.getWriter().write(JSON.toJSONString(isDeleted));
    }


}
